package com.xijia.wuyouwallet.activity;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSONObject;
import com.xijia.wuyouwallet.MyApp;
import com.xijia.wuyouwallet.R;
import com.xijia.wuyouwallet.api.MyCallBack;
import com.xijia.wuyouwallet.base.BaseActivity;
import com.xijia.wuyouwallet.bean.CertCountData;
import com.xijia.wuyouwallet.bean.UpLoadImgData;
import com.xijia.wuyouwallet.utils.CharCheckUtil;
import com.xijia.wuyouwallet.utils.Constants;
import com.xijia.wuyouwallet.utils.MyLogger;
import com.xijia.wuyouwallet.utils.StringUtils;
import com.xijia.wuyouwallet.utils.UrlConfig;
import com.xijia.wuyouwallet.utils.XUtil;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/7/14 0014.
 */

public class AttestationActivity extends BaseActivity implements View.OnClickListener{
    private ImageView attestation_back;
    private EditText attestation_name,attestation_idCard,attestation_bankNumEt,attestation_phoneNumEt;
    private TextView attestation_config;
    private String name;

    private TextView attestation_totalCount,attestation_useCount;

    private int useCount = 0;

    private ImageView attestation_pCard_frontImg,attestation_pCard_backImg,
            attestation_bank_frontImg,attestation_bank_backImg,
            attestation_handPCard_Img;
    private LinearLayout attestation_bankNameLl,attestation_bankCityLl;
    private TextView attestation_bankNameTv,attestation_bankCityTv;


    private String pCard_frontImg=null;
    private String pCard_backImg=null;
    private String bank_frontImg=null;
    private String bank_backImg=null;
    private String handPCard_Img=null;
    private int imgType;

    private String bankName = null;
    private String bankCityCode = null;


    //选择头像
    private PopupWindow selectPhotoPop;
    private RelativeLayout attestation_rl_all;
    //--------------------------------
    private final String IMAGE_UNSPECIFIED = "image/*";
    private final int REQUESTCODE_TAKE = 11;//拍照
    private final int REQUESTCODE_PICK = 12;//相册选取
    private final long PICSIZELIMIT = 480000;
    //获取到的图片路径
    private String picPath = "";
    private Uri photoUri;
    private Bitmap imgBm = null;



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_attestation);
        initView();
    }
    private void initView(){
        attestation_rl_all = (RelativeLayout) findViewById(R.id.attestation_rl_all);
        attestation_back = (ImageView) findViewById(R.id.attestation_back);
        attestation_back.setOnClickListener(this);
        attestation_name = (EditText) findViewById(R.id.attestation_name);
        attestation_idCard = (EditText) findViewById(R.id.attestation_idCard);
        attestation_config = (TextView) findViewById(R.id.attestation_config);
        attestation_config.setOnClickListener(this);
        attestation_totalCount = (TextView) findViewById(R.id.attestation_totalCount);
        attestation_useCount = (TextView) findViewById(R.id.attestation_useCount);
        attestation_pCard_frontImg = (ImageView) findViewById(R.id.attestation_pCard_frontImg);
        attestation_pCard_frontImg.setOnClickListener(this);
        attestation_pCard_backImg = (ImageView) findViewById(R.id.attestation_pCard_backImg);
        attestation_pCard_backImg.setOnClickListener(this);
        attestation_bank_frontImg = (ImageView) findViewById(R.id.attestation_bank_frontImg);
        attestation_bank_frontImg.setOnClickListener(this);
        attestation_bank_backImg = (ImageView) findViewById(R.id.attestation_bank_backImg);
        attestation_bank_backImg.setOnClickListener(this);
        attestation_handPCard_Img = (ImageView) findViewById(R.id.attestation_handPCard_Img);
        attestation_handPCard_Img.setOnClickListener(this);
        attestation_bankNameLl = (LinearLayout) findViewById(R.id.attestation_bankNameLl);
        attestation_bankNameLl.setOnClickListener(this);
        attestation_bankCityLl = (LinearLayout) findViewById(R.id.attestation_bankCityLl);
        attestation_bankCityLl.setOnClickListener(this);
        attestation_bankNameTv = (TextView) findViewById(R.id.attestation_bankNameTv);
        attestation_bankCityTv = (TextView) findViewById(R.id.attestation_bankCityTv);
        attestation_bankNumEt = (EditText) findViewById(R.id.attestation_bankNumEt);
        attestation_phoneNumEt = (EditText) findViewById(R.id.attestation_phoneNumEt);


        residueConut();
    }

    /**
     * 初始化改换头像popup
     */
    private void initPhotoPop() {
        View popView = View.inflate(this, R.layout.popup_select_picture, null);
        selectPhotoPop = new PopupWindow(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        TextView popup_select_tv_photograph = (TextView) popView.findViewById(R.id.popup_select_tv_photograph);
        TextView popup_select_tv_album = (TextView) popView.findViewById(R.id.popup_select_tv_album);
        TextView popup_select_tv_cancel = (TextView) popView.findViewById(R.id.popup_select_tv_cancel);
        RelativeLayout popup_select_rl_all = (RelativeLayout) popView.findViewById(R.id.popup_select_rl_all);
        popup_select_rl_all.getBackground().setAlpha(150);
        popup_select_rl_all.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                selectPhotoPop.dismiss();
            }
        });
        //拍照
        popup_select_tv_photograph.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                selectPhotoPop.dismiss();
                takePhoto();
            }
        });
        //从相册选取
        popup_select_tv_album.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                selectPhotoPop.dismiss();
                pickPhoto();
            }
        });
        popup_select_tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                selectPhotoPop.dismiss();
            }
        });
        selectPhotoPop.setContentView(popView);
        selectPhotoPop.showAtLocation(attestation_rl_all, Gravity.TOP, 0, 0);
    }
    /***
     * 从相册中取图片
     */
    private void pickPhoto() {
        Intent intent = new Intent(Intent.ACTION_PICK, null);
        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_UNSPECIFIED);
        startActivityForResult(intent, REQUESTCODE_PICK);
    }
    /**
     * 拍照获取图片
     */
    private void takePhoto() {
        /*Intent takeIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        //下面这句指定调用相机拍照后的照片存储的路径
        takeIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), IMAGE_FILE_NAME)));
        startActivityForResult(takeIntent, REQUESTCODE_TAKE);*/
        //执行拍照前，应该先判断SD卡是否存在
        String SDState = Environment.getExternalStorageState();
        if (SDState.equals(Environment.MEDIA_MOUNTED)) {
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            //            **
            //         *需要说明一下，以下操作使用照相机拍照，拍照后的图片会存放在相册中的 * 这里使用的这种方式有一个好处就是获取的图片是拍照后的原图 * 如果不使用ContentValues存放照片路径的话，拍照后获取的图片为缩略图不清晰
            ContentValues values = new ContentValues();
            photoUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
            intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, photoUri);
            startActivityForResult(intent, REQUESTCODE_TAKE);
        } else {
            Toast.makeText(this, "内存卡不存在", Toast.LENGTH_LONG).show();
        }
    }

    /**
     * 认证
     */
    private void atation(){
        name = attestation_name.getText().toString().trim();
        if (name.isEmpty()){
            showToast("请输入姓名");
            return;
        }
        String card = attestation_idCard.getText().toString().trim();
        if (card.isEmpty()){
            showToast("请输入身份证卡号");
            return;
        }
        if (!CharCheckUtil.isIDNumber(card)){
            showToast("身份证格式错误");
            return;
        }
        String bankNum = attestation_bankNumEt.getText().toString().trim();
        if (bankNum.isEmpty()){
            showToast("请输入储蓄卡号");
            return;
        }
        if (!CharCheckUtil.checkBankCard(bankNum)){
            showToast("储蓄卡号格式错误");
            return;
        }
        if (bankName==null){
            showToast("请选择开户行");
            return;
        }
        if (bankCityCode==null){
            showToast("请选择开户城市");
            return;
        }
        String phone = attestation_phoneNumEt.getText().toString();
        if (phone.isEmpty()){
            showToast("请输入银行预留手机号");
            return;
        }
        if (!CharCheckUtil.isPhoneNum(phone)){
            showToast("手机号格式错误");
            return;
        }
        if (pCard_frontImg==null){
            showToast("请上传身份证正面照片");
            return;
        }
        if (pCard_backImg==null){
            showToast("请上传身份证反面照片");
            return;
        }
        if (bank_frontImg==null){
            showToast("请上传银行卡正面照片");
            return;
        }
        if (bank_backImg==null){
            showToast("请上传银行卡反面照片");
            return;
        }
        if (handPCard_Img==null){
            showToast("请上传手持身份证照片");
            return;
        }
        Map<String,Object> map = new HashMap<>();
        map.put("token", MyApp.userData.getData().getToken());
        map.put("user",MyApp.userData.getData().getUser_id());
        map.put("card",card);
        map.put("name",name);
        map.put("card_number",bankNum);//储蓄卡号
        map.put("card_bank",bankName);//开户银行
        map.put("card_city_code",bankCityCode);//开户省市
        map.put("card_tel",phone);//预留手机号
        map.put("identity_front",pCard_frontImg);
        map.put("identity_back",pCard_backImg);
        map.put("bankCard_front",bank_frontImg);
        map.put("bankCard_back",bank_backImg);
        map.put("people_bankCard",handPCard_Img);
        XUtil.Post(UrlConfig.ATATION_REALNAME_URL,map,new MyCallBack<String>(){

            @Override
            public void onSuccess(String result) {
                super.onSuccess(result);
                //MyLogger.wLog().e("实名认证result="+result);
                JSONObject jsonObject = JSONObject.parseObject(result);
                if (jsonObject.getInteger("code")==200){
                    MyApp.userData.getData().setCertification_state("1");
                    MyApp.userData.getData().setNick_name(name);
                    MyApp.isRefresh = true;
                    AttestationActivity.this.setResult(Constants.RESULT_DATA);
                    jumpToPage(AttestationSuccessActivity.class);
                    AttestationActivity.this.finish();
                    /*if (MyApp.isAttentionJump){
                        jumpToPage(HomeActivity.class);
                    }*/
                }else {
                    useCount++;
                    attestation_useCount.setText(useCount+"次");
                }
                showToast(jsonObject.getString("msg"));
            }
            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
                //MyLogger.wLog().e("实名认证失败");
            }
        });
    }
    /**
     * 获取剩余次数
     */
    private void residueConut(){
        Map<String,Object> map = new HashMap<>();
        map.put("user",MyApp.userData.getData().getUser_id());
        map.put("token",MyApp.userData.getData().getToken());
        XUtil.Post(UrlConfig.RESIDUE_CONUT_URL,map,new MyCallBack<String>(){

            @Override
            public void onSuccess(String result) {
                super.onSuccess(result);
                //MyLogger.wLog().e("获取剩余认证次数result="+result);
                CertCountData data = JSONObject.parseObject(result,CertCountData.class);
                if (data.getCode()==200){
                    attestation_totalCount.setText(data.getData().getTotal()+"次");
                    useCount = Integer.parseInt(data.getData().getUse());
                    attestation_useCount.setText(useCount+"次");
                }
            }
            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
                MyLogger.wLog().e("获取剩余认证次数onError="+ex.toString());
            }
        });
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode==Constants.REQUEST_DATA&&resultCode==Constants.RESULT_DATA){//开户行
            bankName = data.getStringExtra("bankName");
            attestation_bankNameTv.setText(bankName);
        }else if (requestCode==Constants.REQUEST_DATA&&resultCode==Constants.RESULT_PROVINCE){//开户城市
            bankCityCode = data.getStringExtra("bankCityCode");
            String bankProvinceName = data.getStringExtra("bankProvinceName");
            String bankCityName = data.getStringExtra("bankCityName");
            attestation_bankCityTv.setText(bankProvinceName+" "+bankCityName);
        }
        if (resultCode != RESULT_CANCELED) {
            switch (requestCode) {
                case REQUESTCODE_PICK:
                    doPhoto(requestCode, data);
                    break;
                case REQUESTCODE_TAKE:
                    doPhoto(requestCode, data);
                    break;
            }
        }
    }
    private void uploadPicture(String picPath){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("img", new File(picPath));
        Log.e("info","picPath="+picPath);
        showProgressDialog(false);
        XUtil.UpLoadFile(UrlConfig.UPLOAD_ATTESTION_IMG,map,new MyCallBack<String>(){

            @Override
            public void onSuccess(String result) {
                super.onSuccess(result);
                dismissProgressDialog();
                //MyLogger.wLog().e("上传图片result="+result);
                UpLoadImgData data = JSONObject.parseObject(result,UpLoadImgData.class);
                if (data.getCode()==200){
                    if (imgType==1){
                        pCard_frontImg=data.getData().getUrl();
                        attestation_pCard_frontImg.setImageBitmap(imgBm);
                    }else if (imgType==2){
                        attestation_pCard_backImg.setImageBitmap(imgBm);
                        pCard_backImg=data.getData().getUrl();
                    }else if (imgType==3){
                        attestation_bank_frontImg.setImageBitmap(imgBm);
                        bank_frontImg=data.getData().getUrl();
                    }else if (imgType==4){
                        attestation_bank_backImg.setImageBitmap(imgBm);
                        bank_backImg=data.getData().getUrl();
                    }else if (imgType==5){
                        attestation_handPCard_Img.setImageBitmap(imgBm);
                        handPCard_Img=data.getData().getUrl();
                    }
                }else {
                    showToast(data.getMsg());
                }
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
                dismissProgressDialog();
                //Log.e("info","上传失败"+ex.toString());
            }
        });

    }
    /**
     * 获取选择的图片的地址
     *
     * @param requestCode
     * @param data
     */
    private void doPhoto(int requestCode, Intent data) {
        // 从相册取图片，有些手机有异常情况，请注意
        if (requestCode == REQUESTCODE_PICK) {
            if (data == null) {
                Toast.makeText(this, "选择图片出错", Toast.LENGTH_SHORT).show();
                return;
            }
            photoUri = geturi(data);
            if (photoUri == null || TextUtils.isEmpty(photoUri.getAuthority())) {
                Toast.makeText(this, "选择图片出错", Toast.LENGTH_SHORT).show();
                return;
            }
        }
        String[] pojo = {MediaStore.MediaColumns.DATA};
        // The method managedQuery() from the type Activity is deprecated
        //Cursor cursor = managedQuery(photoUri, pojo, null, null, null);
        Cursor cursor = getContentResolver().query(photoUri, pojo, null, null, null);
        if (cursor != null) {
            int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            picPath = cursor.getString(columnIndex);
            // 4.0以上的版本会自动关闭 (4.0--14;; 4.0.3--15)
            if (Integer.parseInt(Build.VERSION.SDK) < 14) {
                cursor.close();
            }
        }
        // 如果图片符合要求将其上传到服务器
        if (picPath != null && !picPath.isEmpty()) {
            if (picPath.endsWith(".png") || picPath.endsWith(".PNG") || picPath.endsWith(".jpg") || picPath.endsWith(".JPG") || picPath
                    .endsWith(".jpeg") || picPath.endsWith(".JPEG") || picPath.endsWith(".BMP") || picPath.endsWith(".bmp")) {
                Bitmap bm = null;
                try {
                    bm = compScaleBitmap(picPath);
                    if (bm == null) {
                    } else {
                        imgBm = bm;
                    }
                    uploadPicture(picPath);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                Toast.makeText(AttestationActivity.this, "选择的图片格式不支持", Toast.LENGTH_SHORT).show();
            }
        } else {
            Toast.makeText(this, "选择图片路径错误", Toast.LENGTH_SHORT).show();
        }
    }
    /**
     * 解决小米手机获取空地址
     *
     * @param intent
     * @return
     */
    public Uri geturi(android.content.Intent intent) {
        Uri uri = intent.getData();
        String type = intent.getType();
        if (uri.getScheme().equals("file") && (type.contains("image/"))) {
            String path = uri.getEncodedPath();
            if (path != null) {
                path = Uri.decode(path);
                ContentResolver cr = this.getContentResolver();
                StringBuffer buff = new StringBuffer();
                buff.append("(").append(MediaStore.Images.ImageColumns.DATA).append("=").append("'" + path + "'").append(")");
                Cursor cur = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[]{MediaStore.Images.ImageColumns._ID},
                        buff.toString(), null, null);
                int index = 0;
                for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
                    index = cur.getColumnIndex(MediaStore.Images.ImageColumns._ID);
                    // set _id value
                    index = cur.getInt(index);
                }
                if (index == 0) {
                    // do nothing
                } else {
                    Uri uri_temp = Uri.parse("content://media/external/images/media/" + index);
                    if (uri_temp != null) {
                        uri = uri_temp;
                    }
                }
            }
        }
        return uri;
    }
    private Bitmap compScaleBitmap(String fromPath) throws Exception {
        //获取图片的旋转角度，有些系统把拍照的图片旋转了，有的没有旋转
        int degree = readPictureDegree(fromPath);
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = false;
        options.inSampleSize = 4;
        Bitmap bitmap = BitmapFactory.decodeFile(fromPath, options);
        //        *
        //     *把图片旋转为正的方向
        Bitmap xbitmap = rotaingImageView(degree, bitmap);
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        long picbytes = width * height;
        if (picbytes > PICSIZELIMIT) {
            //picPath = fromPath.substring(0, fromPath.lastIndexOf("/") + 1) + StringUtils.createFileName();
            picPath = Environment.getExternalStorageDirectory() + "/" + StringUtils.createFileName();
            FileOutputStream fops = new FileOutputStream(picPath);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            BitmapFactory.Options newOpts = new BitmapFactory.Options();
            // 开始读入图片，此时把options.inJustDecodeBounds 设回true了
            newOpts.inJustDecodeBounds = true;
            Bitmap map = BitmapFactory.decodeByteArray(baos.toByteArray(), 0, baos.toByteArray().length, newOpts);
            // 重新读入图片，注意此时已经把options.inJustDecodeBounds 设回false了
            newOpts.inJustDecodeBounds = false;
            int w = newOpts.outWidth;
            int h = newOpts.outHeight;
            // 现在主流手机比较多是800*480分辨率，所以高和宽我们设置为
            float ww = 1280f;// 这里设置宽度为600f
            float hh = 720f;// 这里设置高度为800f
            // 缩放比。由于是固定比例缩放，只用高或者宽其中一个数据进行计算即可
            int be = 1;// be=1表示不缩放
            if (w > h && w > ww) {// 如果宽度大的话根据宽度固定大小缩放
                be = (int) (newOpts.outWidth / ww);
            } else if (w < h && h > hh) {// 如果高度高的话根据宽度固定大小缩放
                be = (int) (newOpts.outHeight / hh);
            }
            if (be <= 0) be = 1;
            newOpts.inSampleSize = be;// 设置缩放比例
            map = BitmapFactory.decodeByteArray(baos.toByteArray(), 0, baos.toByteArray().length, newOpts);
            //            *
            //     * 把图片旋转为正的方向
            Bitmap xmap = rotaingImageView(degree, map);
            ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
            map.compress(Bitmap.CompressFormat.JPEG, 100, baos1);
            fops.write(baos1.toByteArray());
            fops.flush();
            fops.close();
            return xmap;
        } else {
            picPath = fromPath;
            return xbitmap;
        }
    }
    /**
     * 读取图片属性：旋转的角度
     *
     * @param path
     * @return
     */
    private static int readPictureDegree(String path) {
        int degree = 0;
        try {
            ExifInterface exifInterface = new ExifInterface(path);
            int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
            switch (orientation) {
                case ExifInterface.ORIENTATION_ROTATE_90:
                    degree = 90;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_180:
                    degree = 180;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_270:
                    degree = 270;
                    break;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return degree;
    }
    /**
     * 旋转图片
     *
     * @param angle
     * @param bitmap
     * @return
     */
    private static Bitmap rotaingImageView(int angle, Bitmap bitmap) {
        //旋转图片 动作
        Matrix matrix = new Matrix();
        matrix.postRotate(angle);
        System.out.println("angle2=" + angle);
        // 创建新的图片
        Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        return resizedBitmap;
    }
    public String getDiskCacheDir(Context context) {
        String cachePath = null;
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
                || !Environment.isExternalStorageRemovable()) {
            cachePath = context.getExternalCacheDir().getPath();
        } else {
            cachePath = context.getCacheDir().getPath();
        }
        return cachePath;
    }
    private  File getCacheFile(File parent, String child) {
        // 创建File对象，用于存储拍照后的图片
        File file = new File(parent, child);

        if (file.exists()) {
            file.delete();
        }
        try {
            file.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return file;
    }
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.attestation_back:
                finish();
                break;
            case R.id.attestation_config:
                atation();
                break;
            case R.id.attestation_pCard_frontImg:
                imgType = 1;
                initPhotoPop();
                break;
            case R.id.attestation_pCard_backImg:
                imgType = 2;
                initPhotoPop();
                break;
            case R.id.attestation_bank_frontImg:
                imgType = 3;
                initPhotoPop();
                break;
            case R.id.attestation_bank_backImg:
                imgType = 4;
                initPhotoPop();
                break;
            case R.id.attestation_handPCard_Img:
                imgType = 5;
                initPhotoPop();
                break;
            case R.id.attestation_bankNameLl://开户行名称
                jumpToPage(SelectBankActivity.class,true,Constants.REQUEST_DATA);
                break;
            case R.id.attestation_bankCityLl://开户城市
                jumpToPage(SelectProvinceActivity.class,true,Constants.REQUEST_DATA);
                break;
        }
    }
}
